package com.iis.gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.border.EmptyBorder;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JToolBar;
import javax.swing.JButton;
import javax.swing.GroupLayout;
import javax.swing.UIManager;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JDesktopPane;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class FormUtamaIIS extends JFrame {

	private JPanel contentPane;
	JDesktopPane desktopPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					FormUtamaIIS frame = new FormUtamaIIS();
					
					try {
					    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
					        if ("System".equals(info.getName())) {
					            UIManager.setLookAndFeel(info.getClassName());
					            break;
					        }
					    }
					} catch (Exception e) {
					    // If Nimbus is not available, you can set the GUI to another look and feel.
					}
					
					frame.setVisible(true);
					frame.setTitle("Very Very Simple Insurance System");
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public FormUtamaIIS() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 661, 467);
		
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new BorderLayout(0, 0));
		
		JToolBar toolBar = new JToolBar();
		contentPane.add(toolBar, BorderLayout.NORTH);
		
		JButton btnAgen = new JButton("Agen");
		toolBar.add(btnAgen);
		
		JButton btnSales = new JButton("Sales");
		toolBar.add(btnSales);
		
		JButton btnKlien = new JButton("Klien");
		toolBar.add(btnKlien);
		
		JButton btnAsuransi = new JButton("Asuransi");
		toolBar.add(btnAsuransi);
		
		desktopPane = new JDesktopPane();
		contentPane.add(desktopPane, BorderLayout.CENTER);
		
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		
		JMenu mnSistem = new JMenu("Sistem");
		menuBar.add(mnSistem);
		
		JMenuItem mntmLogin = new JMenuItem("Login");
		mnSistem.add(mntmLogin);
		
		JMenuItem mntmLogout = new JMenuItem("Logout");
		mnSistem.add(mntmLogout);
		
		JMenuItem mntmKeluar = new JMenuItem("Keluar");
		mnSistem.add(mntmKeluar);
		
		JMenu mnMasterData = new JMenu("Master Data");
		menuBar.add(mnMasterData);
		
		JMenuItem mntmAsuransi = new JMenuItem("Asuransi");
		mnMasterData.add(mntmAsuransi);
		
		JMenuItem mntmAgen = new JMenuItem("Agen");
		mnMasterData.add(mntmAgen);
		
		JMenuItem mntmSales = new JMenuItem("Sales");
		mnMasterData.add(mntmSales);
		
		JMenuItem mntmKlien = new JMenuItem("Klien");
		mntmKlien.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				klienKlik(arg0);
			}
		});
		mnMasterData.add(mntmKlien);
		
		JMenu mnTransaksi = new JMenu("Transaksi");
		menuBar.add(mnTransaksi);
		
		JMenuItem mntmTambah = new JMenuItem("Tambah");
		mnTransaksi.add(mntmTambah);
		
		JMenuItem mntmCari = new JMenuItem("Cari");
		mnTransaksi.add(mntmCari);	
		
		
	}
	
	private void klienKlik(ActionEvent arg0){
		FormKlien frmKlien = new FormKlien();
		desktopPane.add(frmKlien);
		frmKlien.show();
	}
}
